<?php
namespace Api;

use Kuyuan\WqCore\api\Api;
use Kuyuan\WqCore\util\Util;

/**
 * 后台首页所需数据
 * Class Home
 * @package Api
 */
class Home extends Api
{
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 获取首页infor所需数据
     */
    public function infor()
    {
        Util::appointGet();
        $_data = array();
        // 用户总数
        $Member = $this->newController("Member");
        $_data[] = $Member->getTotal();
        // 今日新增用户数量
        $_data[] = $Member->getDayMember();
        // 红包总数
        $Red = $this->newController("Red");
        $_data[] = $Red->getTotal();
        // 今日红包数量
        $_data[] = $Red->getDayTotal();
        // 获取系统总收入
        $_data[] = sprintf("%.2f",$Red->getSystemIncome());
        // 获取今日系统收入
        $_data[] = sprintf("%.2f",$Red->getSystemDayIncome());
        Util::returns(array("code"=>0,"data"=>$_data));
    }

    /**
     * 获取后台manage端统计表时间段数据
     */
    public function getStatisticsDate()
    {
        Util::appointGet();
        $_date = $this->_gpc["date"];
        $_data = array();
        $Member = $this->newController("Member");
        $Red = $this->newController("Red");
        foreach ($_date as $_v) {
            $_data["member"][] = $Member->getDayMember($_v);
            $_data["red_number"][] = $Red->getDayTotal($_v);
            $_data["income"][] = sprintf("%.2f",$Red->getSystemDayIncome($_v));
        }
        Util::returns(array("code"=>0,"data"=>$_data));
    }
}